0
如何发送mltiple用户消息使用griview应连接到两个表即登录(从哪里将检索和显示用户名),然后第二个表消息(消息将被存储为特定的用户名)。我已将它连接到登录,但我无法将值插入到消息表中。消息表具有msg_id,用户名和消息列。如何发送多个用户消息使用gridview与模板
这里的设计:
的.aspx
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
EnableModelValidation="True" DataSourceID="SqlDataSource1"
onrowcommand="GridView2_RowCommand">
<Columns>
<asp:BoundField DataField="username" HeaderText="username"
SortExpression="username" />
<asp:BoundField DataField="password" HeaderText="password"
SortExpression="password" />
<asp:BoundField DataField="utype" HeaderText="utype" SortExpression="utype" />
<asp:BoundField DataField="ptype" HeaderText="ptype" SortExpression="ptype" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AutomobileConnectionString14 %>"
SelectCommand="SELECT * FROM [login] WHERE ([utype] LIKE '%' + @utype + '%')">
<SelectParameters>
<asp:Parameter DefaultValue="U" Name="utype" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
aspx.cs代码
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("cc"))
{
TextBox txt1 = (TextBox)GridView2.FooterRow.FindControl("TextBox1");
foreach(GridView gr in GridView2.Rows)
{
CheckBox chk = (CheckBox)gr.FindControl("CheckBox1");
if (chk.Checked)
{
Object ob = GridView2.DataKeys[gr.RowIndex].Value;
}
现在我被困她我怎么能值插入另一个表的消息时,它是已连接到登录表。帮助我,我想在这里完成的是发送消息,以检查用户。
是否定义在GridView中的CommandName = “CC”?你完成的方式是不正确的。 – Janty
是的,我在按钮标签中,我给了命令名=“cc”。 – pawar
你想在消息表格中插入消息时,检查一些复选框并提交按钮?对? – Janty