私は、テキストボックスとグリッドビューを持つフォームを持っています。 "Inward Number"というテキストボックスがあり、そのテキスト変更イベントは常に発生します。別のコントロールのイベントを発生させたいときは、Inward Numberテキストボックスのテキスト変更イベントを発生させるだけです。これは他のすべてのコントロールで発生します。誰かが助けてくれますか?テキストボックスtextchangedイベントは常に発生します
protected void txtInward_No_TextChanged(object sender, EventArgs e)
{
a = 'A';
NewRow();
}
正しい名前を使用しましたが、このエラーが発生します。
<asp:TextBox ID="txtInward_No" runat="server" Width="220px" CssClass="txtbox"
EnableViewState="False"
AutoPostBack="True" ontextchanged="txtInward_No_TextChanged">
</asp:TextBox>
新しい行だけでグリッドに新しい行が作成されます。
プライベートvoid NewRow() { int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dtnew = new DataTable();
dtnew = (DataTable)ViewState["CurrentTable"];
DataRow drr = null;
if (dtnew.Rows.Count > 0)
{
for (int i = 1; i <= dtnew.Rows.Count; i++)
{
TextBox box1 = (TextBox)GridView1.Rows[rowIndex].Cells[2].FindControl("TextBox1");
TextBox box2 = (TextBox)GridView1.Rows[rowIndex].Cells[3].FindControl("TextBox2");
TextBox box3 = (TextBox)GridView1.Rows[rowIndex].Cells[4].FindControl("TextBox3");
TextBox box4 = (TextBox)GridView1.Rows[rowIndex].Cells[5].FindControl("TextBox4");
TextBox box5 = (TextBox)GridView1.Rows[rowIndex].Cells[6].FindControl("TextBox5");
drr = dtnew.NewRow();
if (txtInward_No.Text =="1")
{
drr["InwardNumber"] = txtInward_No.Text + b.ToString();
}
else
{
drr["InwardNumber"] = txtInward_No.Text + a.ToString();
}
drr["Bags"] = box1.Text;
drr["GrossWt"] = box2.Text;
drr["TareWt"] = box3.Text;
drr["NetWt"] = box4.Text;
drr["DCBillWt"] = box5.Text;
rowIndex++;
}
dtnew.Rows.Add(drr);
ViewState["CurrentTable"] = dtnew;
GridView1.DataSource = dtnew;
GridView1.DataBind();
}
}
PrevData();
b++;
a++;
}
asp.netページとイベントハンドラコードのマークアップを投稿できますか? –
私たちはあなたの心を読むことができません。いくつかのコードを入れてください。 –