Problem with GridView
-
I have created my webapp in ASP.NET, C# and MS-Access. in Table I have cell value as, 1 and 0. At the time of binding I want to convert it to On and Off respecively. How can I do it? Please help , as I am new to .NET This is my code. private void Binding() { // create the connection OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/GmoteDeviceControl/App_Data/DeviceCtrl.mdb;User Id=admin;Password=;"); // Open the connection con.Open(); // create the DataSet DataSet ds = new DataSet(); // create the adapter and fill the DataSet OleDbDataAdapter da = new OleDbDataAdapter("Select DEVICE_NAME,CURRENT_STATE from SUBSCRIBER_DEVICES", con); da.Fill(ds); //Binding DataSource with GridView GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); // close the connection con.Close(); } Thank You.
-
I have created my webapp in ASP.NET, C# and MS-Access. in Table I have cell value as, 1 and 0. At the time of binding I want to convert it to On and Off respecively. How can I do it? Please help , as I am new to .NET This is my code. private void Binding() { // create the connection OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/GmoteDeviceControl/App_Data/DeviceCtrl.mdb;User Id=admin;Password=;"); // Open the connection con.Open(); // create the DataSet DataSet ds = new DataSet(); // create the adapter and fill the DataSet OleDbDataAdapter da = new OleDbDataAdapter("Select DEVICE_NAME,CURRENT_STATE from SUBSCRIBER_DEVICES", con); da.Fill(ds); //Binding DataSource with GridView GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); // close the connection con.Close(); } Thank You.
Purish Dwivedi wrote:
Please help , as I am new to .NET
Then why are you writing data driven ASP.NET code ? That's at least three things you're trying to learn at once. Is it for school, or work ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
I have created my webapp in ASP.NET, C# and MS-Access. in Table I have cell value as, 1 and 0. At the time of binding I want to convert it to On and Off respecively. How can I do it? Please help , as I am new to .NET This is my code. private void Binding() { // create the connection OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/GmoteDeviceControl/App_Data/DeviceCtrl.mdb;User Id=admin;Password=;"); // Open the connection con.Open(); // create the DataSet DataSet ds = new DataSet(); // create the adapter and fill the DataSet OleDbDataAdapter da = new OleDbDataAdapter("Select DEVICE_NAME,CURRENT_STATE from SUBSCRIBER_DEVICES", con); da.Fill(ds); //Binding DataSource with GridView GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); // close the connection con.Close(); } Thank You.
Try Using RowDataBound event
-
Try Using RowDataBound event
thanks
-
Try Using RowDataBound event
Thanks for previous reply. It worked for me. I have ON or OFF values in a GridView cell. Based on this value I want to show a button (opposite Toggle (OFF/On) correspondingly) in another cell. This is my code. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.Cells[2].Text== "0") e.Row.Cells[2].Text = "OFF"; else e.Row.Cells[2].Text = "ON"; } please help. Thanks...
-
Thanks for previous reply. It worked for me. I have ON or OFF values in a GridView cell. Based on this value I want to show a button (opposite Toggle (OFF/On) correspondingly) in another cell. This is my code. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.Cells[2].Text== "0") e.Row.Cells[2].Text = "OFF"; else e.Row.Cells[2].Text = "ON"; } please help. Thanks...
You seem to have some trivial work to do, and not be able to work out how to do any of it. Why is this ? Surely no-one is paying for this code, when you have no clue what you're doing ? Just put a button in a column. The cell itself will tell you if your button has to turn it off, or on.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
thanks
thanks for the reply, but a new problem is, that it is changing my column header also. Any help would be appreciated. Thank YOu