ASP.NET - about gridview  ASP.NET - about gridview

Asked By s n
06-Sep-10 07:04 AM
Hello sir,
my gridview looks like this--

<asp:GridView ID="GrdUser" runat="server" AutoGenerateColumns="False"

DataSourceID="SqlDataSource1" ShowHeader="False" Width="1000px">

<Columns>

<asp:BoundField DataField="filedata"

SortExpression="filedata">

 

</asp:BoundField>

<asp:TemplateField>

<ItemTemplate>

<asp:RadioButton ID="rb1" runat="server" GroupName="aaa"

Text='<%# DataBinder.Eval(Container.DataItem,"opt1") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField>

<ItemTemplate>

<asp:RadioButton ID="rb2" runat="server" GroupName="aaa"

Text='<%# DataBinder.Eval(Container.DataItem,"opt2") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField>

<ItemTemplate>

<asp:RadioButton ID="rb3" runat="server" GroupName="aaa"

text='<%# DataBinder.Eval(Container.DataItem,"opt3") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField>

<ItemTemplate>

<asp:RadioButton ID="rb4" runat="server" GroupName="aaa"

Text='<%# DataBinder.Eval(Container.DataItem,"opt4") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField SortExpression="ans" Visible="False">

<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# Bind("ans") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ans") %>'></asp:TextBox>

</EditItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>
filedata contains questions and opt1...opt4 contains options for questions.ans is the answer of questions
When one of the radiobutton is selected i want to get that value to compare with ans column.So,how
i can get selected radiobuttons value.code behind file is vb.net.

  harsh shah replied to s n
07-Sep-10 12:54 AM
Hi,
for go to next question u have put one button or linkbutton in a gridview.
so call a gridview rowcommand event .

in a linkbutton or button set a command name or command argument.
in a command argument bind your question id and on row command event get the question id value and pass to the database and get related right answer.
now find a four radiobutton control from a gridview and check the right answer with radiobutton answer.

For Example:-


<asp:Button ID="Button1" runat="server" Text="Next" CommandArgument='<%# Eval("QuestionID") %>' CommandName="Next" />

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
      if (e.CommandName == "Next")
      {
        int question_id = Convert.ToInt32(e.CommandArgument.ToString());
        //now pass this question_id value to the database and get the right answer
       //after that find radio button control
      }
    }

Let Me know
Regards,

Harsh Shah
Create New Account
help
hello sir am beginner i have worked in gridview. . how to use the edit delete in gridview using asp.net with c# http: / / www.eggheadcafe.com / tutorials / aspnet / bd212ce9-3b25-4d40-9d45-529da663770e / aspnet-basics-gridview-from-database-with-paging-sorting-and-editing.aspx HI In this example i am going to describe how to Insert record or edit or delete record in GridView using SqlDataSource. For inserting record, i've put textboxes in footer row of GridView using
Display images in GridView Hello team, I m new asp.net. I m using GridView in which i need to display images. This images are coming from folder n not from database. Also need a delete button for each image after clicking only dat image get delete Please give me code with GridView declration. Plz help Thanks Kavita There are good example which show image gallary in gridview http: / / msdn.microsoft.com / en-us / library / aa479350.aspx only u need to add delete
how to edit, update and add a new row in gridview using customcode. . . . . hi , please tell me how to edit, update a grid view row and webforms / Gridview_Delete_confirmLS.aspx http: / / www.dreamincode.net / forums / topic / 106258-deleting-a-row-in-a-gridview-using-c%23 / HI Here is the full GridView declaration: <asp:GridView ID = "Customers" runat = "server" AutoGenerateColumns = "False" DataSourceID = "CustomersSqlDataSource" DataKeyNames = "CustomerId" ShowFooter = "true" onrowcommand = "Customers_RowCommand" > <Columns server" ID = "NoDataLastName" / > <asp:Button runat = "server" ID = "NoDataInsert" CommandName = "NoDataInsert" Text = "Insert" / > < / EmptyDataTemplate> < / asp:GridView> Now when we first start the website here is how our GridView will look like, with no data to show, just fields to insert new rows of data: GridView with no data and here is how it will look after we add some fictive to it: GridViewWithData Now lets see how to make all this work behind the scenes: GridView will cooperate with SqlDataSource to enable users to Update and Delete data to our DB
gridview rowedit, update hai guys i have some data indatabase am display into gridview. my requrement is in that displayed gridview .am tring to add rowedit and row delete .it was ok but it can not perform edit&delete how to perform edit and delete using sqlserver database data For Edit , Update and Delete in GridView You have to Implement following Events of GridView- 1. RowEditing 2. RowCancelingEdit 3. RowUpdating 4. RowDeleting Try this code sample .aspx code- <asp:GridView ID = "GridView2" runat = "server" AutoGenerateColumns = "false" DataKeyNames = "empid" onrowcancelingedit = "GridView2_RowCancelingEdit" onrowdeleting = "GridView2_RowDeleting" onrowediting = "GridView2_RowEditing" onrowupdating DataTextField = "Deptid" DataValueField = "DeptId" / > < / EditItemTemplate> < / asp:TemplateField> <asp:CommandField ShowEditButton = "true" ShowDeleteButton = "true" / > < / Columns> < / asp:GridView> .cs code- / / nction to bind Grid private void getdata() { SqlConnection con = new SqlConnection("CONNECTION STRING
how to create a simple image downloading page in asp.net hi everyone. . . . i want to create a page with full of images and i want End(); } refer http: / / aspdotnetmatters.blogspot.com / 2010 / 11 / generate-captcha-image-in-aspnet-simple.html hello, here is the code to download any file on button click protected void LnkDownLink_Click( object this will help you you can use Download Images with a Save As Dialog in ASP.NET refer below link will get source code http: / / www.how-to-asp.net / download-images-with-save-as-dialog / Create a link to a download page like this dialog instead of displaying it. Regards two options you have for that. 1 use the gridview 2. use datalist i will give you example by using the gridview: Take a gridview