asp.net - How to store ButtonField in a datarow where the column is set for ButtonField -
consider following code
protected void button1_click(object sender, eventargs e) { datatable dt = new datatable(); datacolumn dtcol = new datacolumn(); dtcol = new datacolumn("name", typeof(string)); dt.columns.add(dtcol); dtcol = new datacolumn("address", typeof(string)); dt.columns.add(dtcol); dtcol = new datacolumn("account no", typeof(buttonfield)); dt.columns.add(dtcol); buttonfield bfname = new buttonfield { headertext = "account no", datatextfield="account no", text = "klik", buttontype = buttontype.link, commandname = "executeme" }; string[] strdatarow = new string[3]; (int intx = 0; intx < 10; intx++) { strdatarow[0] = "name" + convert.tostring(intx); strdatarow[1] = "address" + convert.tostring(intx); strdatarow[2] = bfname.text; //error type of value has mismatch column typecouldn't store <account no0> in account no column. expected type buttonfield. buttonfield btnfield = bfname; // no error not appear in gridview1 dt.rows.add(new object[] {strdatarow[0], strdatarow[1], strdatarow[2]}); //dt.rows.add(new object[] { strdatarow[0], strdatarow[1], btnfield }); // no error not appear in gridview1 /* error message on strdatarow[2] type of value has mismatch column typecouldn't store <account no0> in account no column. expected type buttonfield. */ } gridview1.datasource = dt; gridview1.databind(); }
how store buttonfield in datarow column set buttonfield. how buttonfield.text appear in each datarow
and
is possible store string value in datarow column set buttonfield. when string click , buttonfield.commandname execute.
note* : girdview code in aspx page follows.
<asp:gridview id="gridview1" runat="server"> </asp:gridview>
thanks in advance...
im not sure question, instead of put button in datatable, suposed impossible why not create gridview , add templatefield containing button.
Comments
Post a Comment