c# - Unable to select my gridview row of data -
i've added gridview asp.net webapp. added select button in gridview. however, when click select button in gridview, receive error
here gridview code
<asp:gridview id="gvnric" runat="server" align="center" width="30%" backcolor="#cccccc" allowsorting="true" onsorting="gvnric_sorting" bordercolor="#999999" borderstyle="solid" borderwidth="3px" cellpadding="4" cellspacing="2" forecolor="black" autogenerateselectbutton="true" onselectedindexchanged="gvnric_selectedindexchanged" allowpaging="true" pagesize="5" onpageindexchanging="gvnric_pageindexchanging"> <footerstyle backcolor="#cccccc" /> <headerstyle backcolor="black" font-bold="true" forecolor="white" /> <pagerstyle backcolor="#cccccc" forecolor="black" horizontalalign="left" /> <rowstyle backcolor="white" /> <selectedrowstyle backcolor="#000099" font-bold="true" forecolor="white" /> <sortedascendingcellstyle backcolor="#f1f1f1" /> <sortedascendingheaderstyle backcolor="#808080" /> <sorteddescendingcellstyle backcolor="#cac9c9" /> <sorteddescendingheaderstyle backcolor="#383838" /> </asp:gridview>
this format of gridview code working out fine other page not current one. why so?
this how bind data in gridview loadgrid. uses loadgrid paging
private void loadgrid() { sqlconnection conn = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring); //conn.connectionstring = "data source = localhost; initial catalog = majorproject; integrated security= sspi"; conn.open(); dataset ds = new dataset(); sqldataadapter da = new sqldataadapter("select nric [nric] memberaccount status = 'unverified'", conn); da.fill(ds); gvnric.datasource = ds.copy(); gvnric.databind(); conn.close(); }
i re-bind using databindbydataset. time gridview sorting
private datatable databindbydataset() { sqlconnection conn = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring); //conn.connectionstring = "data source = localhost; initial catalog = majorproject; integrated security= sspi"; conn.open(); dataset ds = new dataset(); sqldataadapter da = new sqldataadapter("select nric [nric] memberaccount status = 'unverified'", conn); da.fill(ds); conn.close(); return ds.tables[0]; }
all other pages uses 2 different way of binding assist in paging , sorting not gridview. binding codes same both loadgrid , databindbydataset each have different uses. found link asked similiar question doesn't help.
selectedindexchanged code of gridview wrong detect row.
Comments
Post a Comment